<template>
  <a-radio-group v-model="item[text]" :disabled="flag">
    <a-radio
      v-for="(itm, idx) in modifiedList"
      :key="idx"
      :value="itm"
      name="type"
    >
      {{ itm }}
    </a-radio>
  </a-radio-group>
</template>

<script>
export default {
  props: ["item", "text", "flag"],
  data() {
    return {
      modifiedList: [], //修改后的数组
      checkList: [], //选中的数组
    };
  },
  watch: {
    text: {
      handler(newVal, oldVal) {
        /* 判断有选项时拆分为数值形式展示 */
        if (newVal && this.modifiedList.length == 0) {
          this.modifiedList = this.item.PackageSource.split(",");
        }
        /* 监听传入值,如SectionResultStr不为null则为已填写,既赋值 */
        if (
          this.item.SectionResultStr != null &&
          this.item.SectionResultStr != "" &&
          this.checkList.length == 0
        ) {
          this.checkList = this.item.SectionResultStr.split(",");
        }
      },
      immediate: true,
      deep: true,
    },
    checkList: {
      handler(newVal, oldVal) {
        if (newVal) {
          this.item.SectionResultStr = newVal.toString();
        }
      },
      immediate: true,
      deep: true,
    },
  },
};
</script>

<style></style>